[script]
n0=;
n1=;   This section deals with channel mode changes
n2=;   I didn't bother putting in many comments here...
n3=;   If you can't figure it out, you shouldn't even be thinking about changing it!
n4=;
n5=alias emode {
n6=  if (%haveoptions [ $+ [ $1 ] ] ) set %modechan $1
n7=  else set %modechan other
n8=  if ((%mode [ $+ [ %modechan ] ] != $null) && (%enforcemode [ $+ [ %modechan ] ] )) mode $1 %mode [ $+ [ %modechan ] ]
n9=}
n10=alias mtxt if (%urd) { z | echo 1 $me $2 $+ : 3,0Mode change $3- by $1 }
n11=alias sitebyaddy {
n12=  set %len $len($a2($1)) | dec %len 4
n13=  set %ady $right($a2($1),%len)
n14=  return %ady
n15=}
n16=alias tryagain inc %checkattempt [ $+ [ $1 ] ] | .timer 1 5 checkusers $1
n17=alias checkusers {
n18=  if (%checkattempt [ $+ [ $1 ] ] > 18) { set %checkattempt [ $+ [ $1 ] ] 0 | who $1 }
n19=  if (%updatedial [ $+ [ $1 ] ] = $false) { tryagain $1 | halt }
n20=  if (%haveoptions [ $+ [ $1 ] ] ) set %checkchan $1
n21=  else set %checkchan other
n22=  %i = 0 | %deops = 0 | %nicks = ""
n23=  :nx
n24=  inc %i
n25=  set %nick $nick($1,%i)
n26=  if %nick != $null {
n27=    if %nick = $me { if (%euser) altech -s %dis26 $+ %nick $+ : %dis28 $+ hey, that's me! | goto nx }
n28=    set %adr $a5(%nick) | set %level $al(%adr)
n29=    if %level = 10 {
n30=      set %chans $readini $ul whereban $ma(%nick)
n31=      if ((%chans = $null) || ($1 isin %chans)) {
n32=        if (%banlist) {
n33=          set %reason $readini $ul whyban $ma(%nick)
n34=          mode $1 +b-o $ma(%nick) %nick
n35=          if %reason != $null kick $1 %nick banned: %reason
n36=          else kick $1 %nick %default
n37=          writeini $ul lastused $ma(%nick) $ctime
n38=          if (%ekick) altech $1 %dis3 $+ Shitlisted User! %dis4 $+ Kicking %nick
n39=          rtb $ma(%nick) $1
n40=        }
n41=        elseif (%euser) altech $1 %dis30 $+ Warning! %nick matches ban on $ma(%nick) (Ban List not active)
n42=      }
n43=      elseif (%euser) altech $1 %dis30 $+ Warning! %nick matches ban on $ma(%nick) $+ , but it's not banned on $1
n44=    }
n45=    elseif %level = 70 {
n46=      if (%euser) altech -s %dis26 $+ %nick $+ : %dis28 $+ Your clone!
n47=    }
n48=    elseif %level > 18 {
n49=      if ((%euser) && ($isfriend(%nick,$1))) {
n50=        altech -s %dis26 $+ %nick $+ : %dis28 $+ recognized $wordlevel(%level)
n51=        set %rnick $rnick.ady(%adr)
n52=        if %rnick != %nick altech -s %dis29 $+ %nick is really %rnick
n53=      }
n54=      lastseen %rnick
n55=    }
n56=    else {
n57=      if (%idlekick [ $+ [ $1 ] ] ) writeini $mircdiridle.ini $1 %nick $ctime
n58=      if (%euser) altech -s %dis26 $+ %nick $+ : %dis27 $+ ban check ok
n59=      set %site $sitebyaddy(%nick)
n60=      if %nick isop $1 {
n61=        if ($isdeop(%nick,$1)) {
n62=          mode $1 -o %nick
n63=          if (%euser) altech -s %dis30 $+ Deopping %nick $+ ! 3,0(in deop list)
n64=        }
n65=        elseif ($notop(%nick,$1)) {
n66=          if (%bitch [ $+ [ %checkchan ] ] ) {
n67=            set %nicks %nicks %nick | inc %deops
n68=            if %maxmodes // %deops { mode $1 -oooo %nicks | %nicks = "" }
n69=            if (%euser) altech -s %dis30 $+ %nick (opped) is not in userlist! (deopping)
n70=          }
n71=          else {
n72=            if (%euser) altech $1 %dis30 $+ %nick (opped) is not in userlist!
n73=            if ((%tvbitched [ $+ [ $1 ] ] != $true) && (%euser)) { alert | set %tvbitched [ $+ [ $1 ] ] $true | altech 6 $1 Bitch Mode not active on $1 }
n74=          }
n75=        }
n76=      }
n77=      elseif %nick isvo $1 {
n78=        if ($isdeop(%nick,$1)) {
n79=          mode $1 -v $nick
n80=          if (%euser) altech -s %dis30 $+ De-voicing %nick $+ ! (in devoice list)
n81=        }
n82=      }
n83=    }
n84=    goto nx
n85=  }
n86=  if $len(%nicks) > 0 mode $1 -oooo %nicks
n87=}
n88=alias gotops {
n89=  if $1 = %target { deopall $1 | altech -a %dis10 $+ +o obtained on target channel | dh }
n90=  if %tvrevop [ $+ [ $1 ] ] != $null mode $1 -o %tvrevop [ $+ [ $1 ] ]
n91=  if (%tvimanop [ $+ [ $1 ] ] = $false) {
n92=    set %tvimanop [ $+ [ $1 ] ] $true
n93=    emode $1
n94=    set %checkattempt [ $+ [ $1 ] ] 0
n95=    checkusers $1
n96=  }
n97=}
n98=on 1:SERVERMODE:#:{
n99=  mtxt $nick $chan $parms
n100=  if ($me isop $chan) emode $chan
n101=}
n102=on 1:USERMODE:{
n103=  if (%doneinit) {
n104=    if (($usermodes = $null) || ($usermodes = +)) altech -a %dis10 $+ Usermodes are now nothing
n105=    else altech -a %dis10 $+ Usermodes are now $usermodes
n106=    halt
n107=  }
n108=}
n109=on 1:MODE:#:{
n110=  mtxt $nick $chan $parms
n111=  set %key [ $+ [ $chan ] ] $channel($chan).key
n112=  if (($nick != $me) && ($me isop $chan)) emode $chan
n113=}
n114=on 1:OP:#:{
n115=  if $nick = $me goto skip
n116=  if $opnick = $me gotops $chan
n117=  elseif $me isop $chan {
n118=    if $nick = ChanServ goto skip
n119=    if (%haveoptions [ $+ [ $chan ] ] ) set %opchan $chan
n120=    else set %opchan other
n121=    if (($isdeop($opnick,$chan)) && ($notbot($nick,$chan))) {
n122=      mode $chan -o $opnick
n123=      if (%usespecific) altech -s %dis10 $+ De-opping $opnick (in deop list on $chan $+ )
n124=      else altech -s %dis10 $+ De-opping $opnick (in deop list)
n125=    }
n126=    elseif (($notop($opnick,$chan)) && (%bitch [ $+ [ %opchan ] ] )) {
n127=      if ($ismaster($nick,$chan)) {
n128=        altech -s %dis10 $+ $opnick not listed as an op on $chan $+ , allowed because $nick is a master
n129=      }
n130=      else { mode $chan -o $opnick | altech -s %dis10 $+ De-opped $opnick on $chan (not in user list) | speak dee opped $nick , not in your userlist }
n131=    }
n132=  }
n133=  :skip
n134=  mtxt $nick $chan +o $opnick
n135=  log Opped: $opnick ( $+ $a3($opnick) $+ ) opped by $fulladdress on $chan
n136=}
n137=on 1:DEOP:#:{
n138=  if $opnick = $me {
n139=    set %tvimanop [ $+ [ $chan ] ] $false
n140=    if (%revenge) {
n141=      inc %tvrev [ $+ [ $nick ] ]
n142=      if %tvrev [ $+ [ $nick ] ] = 2 { set %tvrevop [ $+ [ $chan ] ] $nick | .timer 1 30 unset %tvrevop [ $+ [ $chan ] ] }
n143=      .timer 1 30 unset %tvrev [ $+ [ $nick ] ]
n144=    }
n145=    if ((%requestops [ $+ [ $chan ] ] ) && (%botnick [ $+ [ $chan ] ] != $null) && ($nick != $me)) {
n146=      if (($gl(%botnick [ $+ [ $chan ] ] ) = 60) && (%botnick [ $+ [ $chan ] ] isop $chan)) raw -q PRIVMSG %botnick [ $+ [ $chan ] ] :op %botpass [ $+ [ $chan ] ]
n147=    }
n148=  }
n149=  elseif (($nick != $me) && ($me isop $chan)) {
n150=    if (%haveoptions [ $+ [ $chan ] ] ) set %deopchan $chan
n151=    else set %deopchan other
n152=    if (($isbot($opnick,$chan)) || ((%protecto [ $+ [ %deopchan ] ] ) && ($nick != $opnick) && ($notmaster($nick,$chan)) && ($isop($opnick,$chan)))) {
n153=      mode $chan +o $opnick
n154=      altech -s %dis10 $+ $nick deopped $opnick, re-opped $opnick
n155=    }
n156=    if (%massdeop [ $+ [ %deopchan ] ] ) {
n157=      if (($isop($nick,$chan)) && (%opexdeop [ $+ [ %deopchan ] ] )) goto skip
n158=      if ($notmaster($nick,$chan)) {
n159=        if (%deops [ $+ [ $a3($nick) ] ] >= 2) {
n160=          adeop $a3($nick) $chan
n161=          kickall $a3($nick) $chan %massdeopmsg
n162=          if (%ekick) {
n163=            if (%ckick) set %temp $chan
n164=            else set %temp -a
n165=            altech %temp %dis3 $+ Mass Deop! %dis4 Kicking $nick from $chan
n166=          }
n167=          if (%smd = ding) ding
n168=          elseif (%smd = speak) speak mass deop, kicking $nick from $nonum($chan)
n169=          elseif (%smd != none) splay %smd
n170=        }
n171=        else { inc %deops [ $+ [ $a3($nick) ] ] 1 | .timer 1 10 unset %deops [ $+ [ $a3($nick) ] ] }
n172=      }
n173=    }
n174=  }
n175=  :skip
n176=  log Deop: $opnick ( $+ $a3($opnick) $+ ) de-opped by $fulladdress on $chan
n177=  mtxt $nick $chan -o $opnick
n178=}
n179=on 1:SERVEROP:#:{
n180=  if $chan = %target { deopall $chan | altech -a %dis10 $+ Serverop detected on target channel | dh }
n181=  mtxt $nick $chan -o $opnick | log Opped: $nick ServerOp: $opnick ( $+ $a3($opnick) $+ ) opped by $nick on $chan
n182=  if $me !isop $chan halt
n183=  if (%haveoptions [ $+ [ $chan ] ] ) set %opchan $chan
n184=  else set %opchan other  
n185=  if (%serverop [ $+ [ %opchan ] ] ) {
n186=    if ((%deopall [ $+ [ %opchan ] ] ) || ($notop($opnick,$chan))) {
n187=      mode $chan -o $opnick
n188=      altech -s %dis10 $+ ServerOp: $nick set mode: +o $opnick (deopped)
n189=      halt
n190=    }
n191=  }
n192=}
n193=on 1:BAN:#:{
n194=  mtxt $nick $chan +b $banmask | if $nick = $me goto done
n195=  if $banmask iswm $a5($me) {
n196=    if $me isop $chan {
n197=      if %maxmodes = 2 mode $chan -b+b $banmask $a3($nick)
n198=      else mode $chan -o-b+b $nick $banmask $a3($nick)
n199=      rtb $a3($nick) $chan
n200=      kick $chan $nick $realtime Ban detected on me!
n201=    }
n202=    altech -a %dis10 $+ Ban on me detected on $chan (by $nick $+ ) | dh
n203=  }
n204=  if ($me !isop $chan) goto done
n205=  if (%haveoptions [ $+ [ $chan ] ] ) set %banchan $chan
n206=  else set %banchan other
n207=  set %count 0
n208=  :nx
n209=  inc %count
n210=  set %nick $ialchan($banmask,$chan,%count).nick
n211=  if %nick != $null {
n212=    if (($isfriend(%nick,$chan)) && ($notmaster($nick,$chan)) && (%monitor [ $+ [ %banchan ] ] )) {
n213=      mode $chan -b $banmask
n214=      altech -s %dis10 $+ Ban $banmask matched %nick $+ , removed (placed by $nick $+ ) 
n215=      goto done
n216=    }
n217=    elseif (($notfriend(%nick,$chan)) && (%matchbans [ $+ [ %banchan ] ] )) {
n218=      kick $chan %nick banned: $banmask by $nick
n219=      if (%ekick) altech -s %dis10 $+ Kicking %nick (matched ban $banmask $+ )
n220=    }
n221=    goto nx
n222=  }
n223=  if (((irc. isin $nick) || (undernet. isin $nick) || (.net isin $nick)) && (%serverbans [ $+ [ %banchan ] ] )) mode $chan -b $banmask
n224=  :done
n225=  Log Ban: $banmask on $chan by $fulladdress
n226=}
n227=on 1:UNBAN:#:{
n228=  mtxt $nick $chan -b $banmask | %p = 0
n229=  if $count($banmask,$chr(32)) = 1 set %bc mode $chan -bb $banmask
n230=  else set %bc mode $chan -b $banmask
n231=  :nx
n232=  inc %p
n233=  if $timer(%p) != $null {
n234=    if $timer(%p).com = %bc .timer $+ $timer(%p) off
n235=    goto nx
n236=  }
n237=  Log Un-ban: $banmask on $chan by $fulladdress
n238=}
n239=on 1:DEVOICE:#:{
n240=  mtxt $nick $chan -v $vnick
n241=  if $nick != $me {
n242=    if (%haveoptions [ $+ [ $chan ] ] ) set %voicechan $chan
n243=    else set %voicechan other
n244=    if (($me isop $chan) && (%protecto [ $+ [ %voicechan ] ] ) && ($isfriend($vnick,$chan)) && ($notmaster($nick,$chan))) {
n245=      mode $chan +v $vnick
n246=      altech -s %dis10 $+ Re-Voiced $vnick (De-Voiced by $nick on $chan $+ )
n247=    }
n248=  }
n249=  Log Devoice: $vnick ( $+ $a3($vnick) $+ ) was de-voiced on $chan by $fulladdress
n250=}
n251=on 1:VOICE:#:{
n252=  mtxt $nick $chan +v $vnick
n253=  if (($me isop $chan) && ($nick != $me)) {
n254=    if (($isdeop($vnick,$chan)) && ($notbot($nick,$chan))) {
n255=      mode $chan -v $vnick
n256=      if (%usespecific) altech -s %dis10 $+ De-voicing $vnick (in devoice list on $chan $+ )
n257=      else altech -s %dis10 $+ De-voicing $vnick (in devoice list)
n258=    }
n259=  }
n260=  Log Voice: $vnick ( $+ $a3($vnick) $+ ) was voiced on $chan by $fulladdress
n261=}
